﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace AsycServer
{
    /// <summary>
    /// 服务端连接请求
    /// </summary>
    public partial class AsyUdpServer
    {
        void AcceptThread()
        {
            tcpSocket.Start();

            while (Active)
            {
                try
                {
                    Socket s = tcpSocket.AcceptSocket();
                    ClientConnected(s);
                }
                catch (Exception e)
                {
                    CatchException(e);
                    break;
                }
            }
        }
        
        
        void ClientConnected(Socket s)
        {
            Client c = new Client(nmbrOfClients, s, this);
            clientList.Add(c);
            c.SendAcceptPoll();

            nmbrOfClients++;
        }
    }
}